package hebClustering.nlp;

/**
 * A representation of a token (word or phrase).
 *
 */
public class Token {
	
	private String text;
	private int id;
	private int numAppearencesInCorpus;
	
	/**
	 * Creates a new Token, with a given text and id.
	 * 
	 * @param text
	 * @param i
	 */
	public Token(String text, int i) {
		this.text = text;
		id = i;
		numAppearencesInCorpus = 1;
	}

	/**
	 * Sets the text of the token.
	 * 
	 * @param text 
	 */
	public void setText(String text) {
		this.text = text;
	}
	
	/**
	 * Gets the text of the token.
	 * 
	 * @return The text.
	 */
	public String getText() {
		return text;
	}
	
	/**
	 * Sets the id of the token.
	 * 
	 * @param id 
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * Gets the id of the token.
	 * 
	 * @return The id.
	 */
	public int getId() {
		return id;
	}

	/**
	 * Add one to the number of appearances of this token in the corpus.
	 */
	public void addAppearence() {
		numAppearencesInCorpus++;
	}

	/**
	 * Get the number of appearances of this token in the corpus.
	 * 
	 * @return Number of appearances.
	 */
	public int getNumAppearencesInCorpus() {
		return numAppearencesInCorpus;
	}
	
	/**
	 * Return a string representation of the token.
	 * 
	 * @return A string representation.
	 */
	public String toString(){
		return String.format("#%d: %s = %d", id,text,numAppearencesInCorpus);
	}
	

}
